package com.example.recruitment.service.impl;

import com.example.recruitment.entity.Resume;
import com.example.recruitment.mapper.ResumeMapper;
import com.example.recruitment.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeMapper resumeMapper;

    @Override
    public List<Resume> findAll() {
        return resumeMapper.findAll();
    }

    @Override
    public Resume findById(Long id) {
        return resumeMapper.findById(id);
    }

    @Override
    public List<Resume> findByUserId(Long userId) {
        return resumeMapper.findByUserId(userId);
    }

    @Override
    public List<Resume> findByJobId(Long jobId) {
        return resumeMapper.findByJobId(jobId);
    }

    @Override
    @Transactional
    public boolean add(Resume resume) {
        return resumeMapper.insert(resume) > 0;
    }

    @Override
    @Transactional
    public boolean update(Resume resume) {
        return resumeMapper.update(resume) > 0;
    }

    @Override
    @Transactional
    public boolean deleteById(Long id) {
        return resumeMapper.deleteById(id) > 0;
    }

    @Override
    @Transactional
    public boolean updateStatus(Long id, String status) {
        return resumeMapper.updateStatus(id, status) > 0;
    }

    @Override
    public long count() {
        return resumeMapper.count();
    }

    @Override
    public List<Resume> findLatest(int limit) {
        return resumeMapper.findLatest(limit);
    }

    @Override
    public long countByStatus(String status) {
        return resumeMapper.countByStatus(status);
    }
} 